package com.srd.phone.mvp.presenters;

import android.content.Context;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;

import com.shengrongdai.srd.R;
import com.srd.phone.mvp.interfaces.LaunchView;

import java.lang.ref.WeakReference;

public class LaunchPresenter {


    private Context mContext;
    private WeakReference<LaunchView> mLaunchView;

    public LaunchPresenter(Context context, LaunchView launchView) {
        this.mContext = context;
        this.mLaunchView = new WeakReference<LaunchView>(launchView);
    }

    public void initialized() {
        Animation animation = AnimationUtils.loadAnimation(mContext, R.anim.splash);
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                mLaunchView.get().gotoHome();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        mLaunchView.get().animateBackgroundImage(animation);

    }
}

